# models.py
from django.db import models


class Borrowed(models.Model):
    borrower = models.CharField(max_length=30, verbose_name="借书人")
    phone = models.CharField(max_length=60, verbose_name="电话")
    id_number = models.CharField(max_length=60, verbose_name="证件号")
    borrow_date = models.DateTimeField(max_length=60, verbose_name="借书日期")
    borrow_term = models.IntegerField(verbose_name="借书期限")
    borrow_price = models.CharField(max_length=10, verbose_name="借书余额")

    class Meta:
        verbose_name = "借书信息"
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.borrower


class Book(models.Model):
    name = models.CharField(max_length=300, verbose_name="书名")
    description = models.CharField(max_length=500, blank=True, default='', verbose_name="简介描述")
    publisher = models.CharField(max_length=255, blank=True, default='', verbose_name="出版社")
    add_date = models.DateTimeField(auto_now_add=True, verbose_name="添加日期")
    author = models.CharField(max_length=50, blank=True, default='', verbose_name="作者")
    years = models.CharField(max_length=50, blank=True, default='', verbose_name="发行年代")
    price = models.CharField(max_length=300, blank=True, default='', verbose_name="书籍价格")
    country = models.CharField(max_length=100, blank=True, default='', verbose_name="作者国家")
    genre = models.CharField(max_length=50, blank=True, default='', verbose_name="文学体裁")
    douban_score = models.CharField(max_length=5, blank=True, default='', verbose_name="豆瓣评分")

    class Meta:
        verbose_name = "书籍信息"
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.name
